/*mettre dans ce fichier les fonctions non m�tiers utilis�es � diff�rents endroits*/

 
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

#include "utils.h"

void getDateCourante(int *secondes, int *minutes, int *heures, int *jour, int *mois, int *annee)
{
	time_t temps;
	struct tm* currTm;
	char buffer[2];
	
	temps = time(NULL);
	currTm = localtime(&temps);
	strftime(buffer, sizeof(buffer), "%H", currTm);
	*heures = atoi(buffer);
	strftime(buffer, sizeof(buffer), "%M", currTm);
	*minutes = atoi(buffer);
	strftime(buffer, sizeof(buffer), "%S", currTm);
	*secondes = atoi(buffer);
	strftime(buffer, sizeof(buffer), "%d", currTm);
	*jour = atoi(buffer);
	strftime(buffer, sizeof(buffer), "%m", currTm);
	*mois = atoi(buffer);
	strftime(buffer, sizeof(buffer), "%y", currTm);
	*annee = atoi(buffer); //seulement les 2 derniers chiffres (ex si on est en 2011, alors on aura 11)

	
}
char * substring(char * string , int numPartie, char separateur)
{
	int i=1;
	char *pInt;
	char * stringInt = malloc(10*sizeof(char));
	while(i<numPartie)
	{
		if(*string == separateur)
			i++;
		string++;
	}
	printf("i : %d",i);
	pInt = stringInt;
	while(*string !=separateur && *string!='\0')
	{
		*stringInt = *string;
		stringInt++;
		string++;
	}
	*stringInt='\0';
	stringInt = pInt;
	return stringInt;
	
}
